use clap::Parser;
use iroh_app::{Args, Command};
use n0_snafu::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let args = Args::parse();

    // parse the cli command and call the appropriate function
    match &args.command {
        Command::Open { topic } => {
            iroh_app::open(
                *topic,
                args.secret_key,
                args.relay,
                args.no_relay,
                args.name,
                args.bind_port,
            )
            .await?;
        }
        Command::Join { ticket } => {
            iroh_app::join(
                ticket.clone(),
                args.secret_key,
                args.relay,
                args.no_relay,
                args.name,
                args.bind_port,
            )
            .await?;
        }
    }

    Ok(())
}
